<!DOCTYPE html>
<html>
<head>
<title>Fresnel Diffraction Diagram</title>
<style>
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
        background-color: #f8f9fa;
    }
    canvas {
        border: 1px solid #dee2e6;
        background-color: #ffffff;
    }
</style>
</head>
<body>

<canvas id="physicsCanvas" width="500" height="400"></canvas>

<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // Style settings to emulate the hand-drawn look of the source image
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2;
    ctx.lineCap = 'round';

    // --- Define coordinates and dimensions ---
    const centerX = 250;
    const centerY = 200;
    const apertureRadius = 50;
    const zAxisStartX = 40;
    const zAxisEndX = 450;

    // --- Draw Components ---

    // 1. Draw the screen (plane) in perspective
    // Using a quadrilateral that approximates the perspective in the original drawing.
    ctx.beginPath();
    ctx.moveTo(180, 80);  // Top-left
    ctx.lineTo(330, 65);  // Top-right
    ctx.lineTo(320, 335); // Bottom-right
    ctx.lineTo(170, 320); // Bottom-left
    ctx.closePath();
    ctx.stroke();

    // 2. Draw the z-axis with its arrow
    // a) Axis line
    ctx.beginPath();
    ctx.moveTo(zAxisStartX, centerY);
    ctx.lineTo(zAxisEndX, centerY);
    ctx.stroke();

    // b) Arrowhead
    const headlen = 12;
    const arrowAngle = Math.PI / 9;
    ctx.beginPath();
    ctx.moveTo(zAxisEndX, centerY);
    ctx.lineTo(zAxisEndX - headlen * Math.cos(arrowAngle), centerY - headlen * Math.sin(arrowAngle));
    ctx.stroke();
    ctx.beginPath();
    ctx.moveTo(zAxisEndX, centerY);
    ctx.lineTo(zAxisEndX - headlen * Math.cos(arrowAngle), centerY + headlen * Math.sin(arrowAngle));
    ctx.stroke();

    // 3. Draw the circular aperture
    ctx.beginPath();
    ctx.arc(centerX, centerY, apertureRadius, 0, 2 * Math.PI);
    ctx.stroke();

    // 4. Draw the radius 'a' with its arrow
    const radiusArrowYStart = centerY;
    const radiusArrowYEnd = centerY - apertureRadius;
    
    // a) Arrow shaft
    ctx.beginPath();
    ctx.moveTo(centerX, radiusArrowYStart);
    ctx.lineTo(centerX, radiusArrowYEnd);
    ctx.stroke();

    // b) Arrowhead (filled triangle)
    ctx.beginPath();
    ctx.moveTo(centerX, radiusArrowYEnd); // Tip
    ctx.lineTo(centerX - 6, radiusArrowYEnd + 12); // Bottom-left
    ctx.lineTo(centerX + 6, radiusArrowYEnd + 12); // Bottom-right
    ctx.closePath();
    ctx.fill();

    // --- Draw Labels ---
    // Using a serif font to match the original image's style
    ctx.textAlign = 'center';
    
    // '2028'
    ctx.font = 'bold 24px serif';
    ctx.fillText('2028', centerX, 45);

    // 'Fig. 2.30'
    ctx.font = 'bold 20px serif';
    ctx.fillText('Fig. 2.30', centerX, 380);

    // 'O' - The origin label
    ctx.font = '20px serif';
    ctx.fillText('O', centerX, centerY + 25);

    // 'a' - The radius label
    ctx.textAlign = 'right';
    ctx.font = 'italic 22px serif';
    ctx.fillText('a', centerX - 10, centerY - apertureRadius / 2);

    // 'z' - The axis label
    ctx.textAlign = 'center';
    ctx.font = 'italic bold 22px serif';
    ctx.fillText('z', zAxisEndX, centerY + 25);

</script>

</body>
</html>